	<?php 
	include 'header.php';
	//echo "<pre>";print_r($_GET);exit;
	if(count($_POST)){
	if(mysql_query("update admin_user set password='".md5($_POST['password'])."',token='' where email_id='".base64_decode($_GET['email'])."'"))
	{
		header("location:index.php?reset=success");
	}else{
		header("location:reset-password.php?token=".$_GET['token']."&email=".$_GET['email']."&reset=fail");
	}
	}
	?>
		<div style="background:#f5f5f5">
			<div class="wrapper">
				<?php if(isset($_GET['token']) && $_GET['token']!=''){
					$query = mysql_query("SELECT user_id from admin_user where email_id='".base64_decode($_GET['email'])."' and token='".$_GET['token']."'");
					$row=mysql_fetch_row($query);
					if($row!=''){ ?>
					
				<div >
					<div class="span4">
						<form class="login" id="reset_form" name="reset_form" method="POST" action="" >
						<h1>Reset Passwprd</h1>
						<div class="inputs ">
							<input class="password span3" id="password" name="password" type="password" placeholder="Password" autofocus required>   
							<input class="password span3" id="cnf_password" name="cnf_password" type="password" placeholder="Confirm Password" required> 
						</div>
						<div id="actions">
							<a onClick="sendFgtEmail();" class="submit" href="javascript:void(0)">Reset</a>
						</div>
						<div class="clear"></div>
						</form>
					</div>
				</div>
				<?}else{echo "Provide link has been expired or invalid";}}else
				{
					echo "Provide link has been expired or invalid";
				}
				?>
			</div>
		</div>
	</div>
	</div>
	<?php
	include 'footer.php';
	?>
	<script type="text/javascript">
	function sendFgtEmail()
	{
	
		var password = $("#password").val().trim();;
		var cnf_password = $("#cnf_password").val().trim();

		if( password == "" )
		{
			alert( "Please enter password" );
			$("#password").focus();
			return false;
		}
		if( cnf_password == "" )
		{
			alert( "Please enter confirm password" );
			$("#cnf_password").focus();
			return false;
		}

		if( password != cnf_password )
		{
			alert( "Please enter password and confirm password as same" );
			$("#password").focus();
			return false;
		}
		else{
		$("#reset_form").submit();
		}
	}
	</script>
</html>